import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import VueSetupExtend from 'vite-plugin-vue-setup-extend'
import { lastCommitPlugin } from './src/plugin/last-commit-msg/index.js'
import Inspect from 'vite-plugin-inspect'

// https://vitejs.dev/config/
export default defineConfig({
	define: {
		'__VUE_PROD_HYDRATION_MISMATCH_DETAILS__': false
	},
	plugins: [
		vue(),
		VueSetupExtend(),
		lastCommitPlugin(),
		Inspect({
		  build: true,
		  outputDir: '.vite-inspect'
		})
	],
	resolve: {
		alias: {
			'@': resolve(__dirname, 'src'), // 设置 `@` 指向 `src` 目录
			// 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js'
		}
	},
	server: {
		open: true,
		host: '0.0.0.0', // 设置本地Network
		proxy: {
			"/api": {
				target: 'http://127.0.0.1:3000/api', // 本地服务器
				changeOrigin: true,
				secure: false,
				// rewrite: path => path.replace(/^\/api/, '')
			},
		},
	},
	css: {
		preprocessorOptions: {
		  scss: {
			additionalData: `@import '@/style/base.scss';`
		  },
		},
	  },
})
